        var selected_index = 1;
        var position_left = 2;
        var click_item = 0;
	   /*Ham di chuyen lua chon*/
        function move(item, position) {
            $("div.item-2").animate({ "margin-left": position }, 500);
             var item_obj = compare_obj("anhgt-" + selected_index);
            $("div#view").css("background-image", "url('"+item_obj.photo+"')");
        }
        /*Tu dong di chuyen vung lua chon trong vong 4 giay*/
        function auto_move() {
            action();
            click_item = 1;
            if (selected_index == 1) {
				 var view_size = $("div#view").css("height").substr(0, 3);
				 var des_size = $("div#description").css("height").substr(0, 2);
				 var item_obj = compare_obj("anhgt-" + selected_index);
                $("div#description").animate({ "margin-top": view_size+"px" });
                $("div#description").text(item_obj.description);
                $("div#description").animate({ "margin-top": ( parseInt(view_size) -  parseInt(des_size))+"px" }, 500);
            }
            //kiem tra item co phai item cuoi khong
            if (items_list.length == selected_index) {
                selected_index = 1;
            }
            else {
                selected_index += 1;
            }

            setTimeout("auto_move()", 6000);
        }
        function action() {
			var view_size = $("div#view").css("height").substr(0, 3);
			var des_size = $("div#description").css("height").substr(0, 2);
            var item_obj = compare_obj("anhgt-" + selected_index);
            move($("div#anhgt-" + selected_index), item_obj.position);
            var color = $("div#item-palce div#anhgt-" + selected_index).css("background-color");
            $("div#view").css("background-color", color);
            if (click_item == 1) {
                $("div#description").animate({ "margin-top": view_size+"px" });
                $("div#description").text(item_obj.description);
                $("div#description").animate({ "margin-top": ( parseInt(view_size) -  parseInt(des_size))+"px" }, 500);
                click_item = 0;
            }
        }
        /*Lay ve doi tuong dua theo id*/
        function compare_obj(id) {
            var select_item = null;
            for (var i = 0; i < items_list.length; i++) {
                if (items_list[i].id == id) {
                    select_item = items_list[i];
                    break;
                }
            }
            return select_item;
        }
        function move_next() {
            //Lay do dai cua toan bo danh sach item
            var list_leght = $("div#user_interaction ul").css("width");
            var list_leght_subString = list_leght.substr(0, parseInt(list_leght.length) - 2);
            var list_current_leght = $("div#item-list").css("width");
            var list_current_leght_subString = list_current_leght.substr(0, parseInt(list_current_leght.length) - 2);
            var max_next = $("div#user_interaction").css("left");
            var roll_back = position_left;
            position_left = position_left + parseInt(list_current_leght_subString);
            if (list_leght_subString > position_left) {
                $("#user_interaction").animate({ "left": "-" + position_left + "px" }, "slow");
            }
            else {
                position_left = roll_back;
            }

        }
        function move_prev() {
            //Lay do dai cua toan bo danh sach item
            var list_leght = $("div#user_interaction ul").css("width").substr(0, 3);
            var list_current_leght = $("div#item-list").css("width").substr(0, 3);
            var max_next = $("div#user_interaction").css("left");
            var roll_back = position_left;
            if (position_left > 0) {
                position_left = position_left - parseInt(list_current_leght);
            }

            if (position_left > 0) {
                $("#user_interaction").animate({ "left": "+" + position_left + "px" }, "slow");
            }
            else {
                position_left = roll_back;
            }
        }

        $(document).ready(function () {
            $(".item").click(function () {
                var item = $(this).attr("id");
                var result = compare_obj(item);
                if (result.id == item) {
                    selected_index = result.index;
                    click_item = 1;
                    action($(this), result.position);
                }

            });
            $("div#item-prev").click(function () {
                move_prev();
            });
            $("div#item-next").click(function () {
                move_next();
            });
        })